/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package org.sbbs.secret.entity;

import java.util.Objects;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import org.sbbs.base.entity.IdentityBaseEntity;

/**
 *
 * @author Mr.fdc <fdc_messenger@126.com>
 * 用户公匙负责加密
 */
@Entity
@Table(name = "SEC_SECRET")
public class Secret extends IdentityBaseEntity {

    private SecretUser secretUser;
    private String secretName;
    private String secretValue;

    @ManyToOne(fetch = FetchType.EAGER)
    @JoinColumn(name = "USER_ID", nullable = true)
    public SecretUser getSecretUser() {
        return secretUser;
    }

    public void setSecretUser(SecretUser secretUser) {
        this.secretUser = secretUser;
    }

    @Column(length = 500, name = "SECRET_NAME", nullable = false)
    public String getSecretName() {
        return secretName;
    }

    public void setSecretName(String secretName) {
        this.secretName = secretName;
    }

    @Column(length = 1000, name = "SECRET_VALUE", nullable = false)
    public String getSecretValue() {
        return secretValue;
    }

    public void setSecretValue(String secretValue) {
        this.secretValue = secretValue;
    }

    @Override
    public int hashCode() {
        int hash = 5;
        hash = 37 * hash + Objects.hashCode(this.secretUser);
        hash = 37 * hash + Objects.hashCode(this.secretName);
        hash = 37 * hash + Objects.hashCode(this.secretValue);
        return hash;
    }

    @Override
    public boolean equals(Object obj) {
        if (this == obj) {
            return true;
        }
        if (obj == null) {
            return false;
        }
        if (getClass() != obj.getClass()) {
            return false;
        }
        final Secret other = (Secret) obj;
        if (!Objects.equals(this.secretName, other.secretName)) {
            return false;
        }
        if (!Objects.equals(this.secretValue, other.secretValue)) {
            return false;
        }
        if (!Objects.equals(this.secretUser, other.secretUser)) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "Secret{" + "secretUser=" + secretUser + ", secretName=" + secretName + ", secretValue=" + secretValue + '}';
    }

}
